package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.Employee;
import com.kaishengit.util.db.DBHelp;
import com.kaishengit.util.db.RowMapper;

public class EmployeeDao {

	private DBHelp<Employee> db = new DBHelp<Employee>();
	
	public Employee findByName(String name) {
		String sql = "select id,name,password,pic from t_employee where name = ?";
		return db.executeQueryToObject(sql, new EmployeeRowMapper(), name);
	}
	
	public class EmployeeRowMapper implements RowMapper<Employee>{

		public Employee mapRow(ResultSet rs) throws SQLException {
			Employee em = new Employee();
			em.setId(rs.getString("id"));
			em.setName(rs.getString("name"));
			em.setPassword(rs.getString("password"));
			em.setPic(rs.getString("pic"));
			return em;
		}
		
	}
}
